import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const Home = () => import('../views/home/Home'),
  RecomMend = () => import('../views/recommend/RecomMend'),
  Sort = () => import('../views/sort/Sort'),
  ProFile = () => import('../views/profile/ProFile');



Vue.use(VueRouter)

const originalReplace = VueRouter.prototype.replace
VueRouter.prototype.replace = function replace(location) {
  return originalReplace.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '',
    redirect: '/home'
  },
  {
    path: '/home',
    component: Home
  },
  {
    path: '/recommend',
    component: RecomMend
  },
  {
    path: '/sort',
    component: Sort
  },
  {
    path: '/profile',
    component: ProFile
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
